/*
 * $Id: InfoBar.java 149 2009-05-15 15:24:13Z meyer@alphatec.de $
 * 
 *
 * Copyright 2009 DeltaDesk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package deltadesk.deepspace.widget;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;

import deltadesk.gui.deltagui.widget.Canvas;

/**
 * InfoBar.
 * 
 * @author Andreas Meyer
 * @version $Revision: 149 $
 */
public class InfoBar extends Canvas {
	
	
	/**
	 * Construct the infobar.
	 */
	public InfoBar() {
		setOpaque(false);
	}

	/**
	 * @see deltadesk.gui.deltagui.widget.AbstractControl#renderControl(java.awt.Graphics2D)
	 */
	@Override
	protected void renderControl(final Graphics2D g2) {

		final String txt = "Welcome to DeltaDesk";
		final String txt2 = "V0.0.8";
		final Font f = getStyle().getFont().deriveFont(Font.BOLD);
		g2.setFont(f);
		
		final FontMetrics fm = g2.getFontMetrics(f);
		int h = fm.getHeight();

		int x = 5;
		int y = h + 1;
		drawStringAccented(g2, txt, x, y);
		
		x += fm.stringWidth(txt) + 5;
		
		g2.setFont(getStyle().getFont());
		drawStringAccented(g2, txt2, x, y);
		
		x += fm.stringWidth(txt2) + 5;
		drawStringAccented(g2, " :: Desktop : Applications : Graphics : PhotoViewer : Album 1 ::", x, y);

	}
	
	/**
	 * Draw a string accented.
	 * 
	 * @param g2
	 * @param text
	 * @param x
	 * @param y
	 */
	private void drawStringAccented(final Graphics2D g2, 
			                        final String text, 
			                        final int x, final int y) {

		//TODO: Use foreground color
		g2.setColor(Color.WHITE);
		g2.drawString(text, x, y + 1);
		g2.setColor(Color.BLACK);
		g2.drawString(text, x, y);
	}

}
